$(function () {
    window.app.page['docDetail'] = {
        divDocDetail: $('#docDetail'),
        id: window.app.util.getUrlParam('id'),
        viewModel: function (data) {
            var self = this;
            self.doc = data.data;
        }
    };

    window.app.page.docDetail.fn = {
        init: function () {
            window.app.util.restClient('/thirdPart/nmgat/docDetail/' + window.app.page.docDetail.id, null, function (data) {
                ko.applyBindings(new window.app.page.docDetail.viewModel(data), window.app.page.docDetail.divDocDetail[0]);

                var imgSrcList = [];
                var allImgNodes = $('.doc_content').find('img');
                $.each(allImgNodes, function (index, item) {
                    imgSrcList.push($(item).attr('src'));
                });

                $.each(allImgNodes, function (index, item) {
                    $(item).bind('click', function () {
                        $.photoBrowser({
                            items: imgSrcList
                        }).open(index);
                    });
                });
                $.hideLoading();
            })
        }
    };

    window.app.route.docDetail.successFun = window.app.page.docDetail.fn.init;
});